#ifndef __OS_MUTEX_H
#define __OS_MUTEX_H

#include "osEvent.h"



typedef struct _MUTEX
{   
    EVENT_T     event;          // 互斥锁事件等待队列
    TASK_T      *owner;         // 互斥锁所有者
    uint32_t    ownerOriginPrio;// 互斥锁所有者原始优先级
    uint32_t    lockCount;      // 互斥锁嵌套次数
} MUTEX_T;


typedef struct _MUTEX_INFO
{   
    TASK_T      *owner;         // 互斥锁所有者
    uint32_t    ownerOriginPrio;// 互斥锁所有者原始优先级
    uint32_t    ownerNowPrio;   // 互斥锁当前优先级    
    uint32_t    lockCount;      // 互斥锁嵌套次数
    uint32_t    taskCount;      // 互斥事件等待队列任务数量
} MUTEX_INFO_T;



extern void     vMutexInit(MUTEX_T *mutex);
extern uint32_t vMutexWait(MUTEX_T *mutex, uint32_t timeout);
extern uint32_t vMutexNoWait(MUTEX_T *mutex);
extern uint32_t vMutexNotify(MUTEX_T *mutex);
extern uint32_t vMutexDestroy(MUTEX_T *mutex);
extern void     vMutexGetInfo(MUTEX_T *mutex, MUTEX_INFO_T *info);

#endif // __OS_MUTEX_H
